/****************************************************************************
 * 	 <SPG2 - Secure Password Generator>
 *   Copyright (C) 2010  <Robert Carr>
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *   @author Robert Carr (etftw)
 *   @version 2.4
 *   
 ***************************************************************************/

package spg2;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class AboutDialog extends JDialog implements ActionListener 
{
	private static final long serialVersionUID = -4365850705012233689L;
	
	/**
	 * Initialises and sets up the about dialog window
	 * @param parent the parent JFrame (i.e. the main SPG2 window)
	 */
	public AboutDialog(JFrame parent) 
	{
		super(parent, "About", true);
	    if (parent != null) 
	    {
	      Dimension parentSize = parent.getSize(); 
	      Point p = parent.getLocation(); 
	      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
	    } 
	    
	    JLabel jlbTitle = new JLabel("<html><h1>SPG2 v1.4</h1>" +
	    		"<p><a href='http://code.google.com/p/spg2/'>http://code.google.com/p/spg2/</a></p><br>" +
	    		"<p>Copyright (C) 2010  Robert Carr</p><br>" +
	    		"<p><em>This program is free software: you can redistribute it and/or modify" +
	    		"it under the terms of the GNU General Public License as published by" +
	    		" the Free Software Foundation, either version 3 of the License, or" +
	    		"(at your option) any later version.</em></p>" +
	    		"</html>");
	    
	    jlbTitle.setLocation( 20, 0 );
	    jlbTitle.setSize(262, 220);
	    jlbTitle.setVisible(true);
	    
	    this.setLayout(null);
	    getContentPane().add( jlbTitle );
	    
	    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	    this.setSize( 315, 280 );
	    setVisible(true);
	  }
	
	public void actionPerformed(ActionEvent e) 
	  {
	    setVisible(false); 
	    dispose(); 
	  }
}
